home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2510.ZIP / TRSOURCE.EXE / DEPVALSL.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  1KB  |  45 lines

  1. /*********
  2. *
  3. * DEPVALSL.C
  4. *
  5. * by Ralph Davis
  6. * modified by Tom Rettig
  7. *
  8. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  9. *
  10. *********/
  11.  
  12. /* DEPVALSL:  Depreciated value by straight-line method
  13.  
  14.               Computes current value of an asset by 
  15.                   straight-line method.
  16.  
  17.               SYNTAX:  DEPVALSL(purchase, resale, total periods,
  18.                                                   periods to date)
  19.  
  20.                        where    purchase = initial purchase price
  21.                                 resale   = anticipated resale value
  22.                           total periods  = total time of service
  23.                         periods to date  = time periods to be calculated
  24.  
  25.               RETURNS;  current value
  26. */
  27.  
  28. #include "trlib.h"
  29.  
  30. TRTYPE depvalsl()
  31. {
  32.    if ( PCOUNT==4 && ISNUM(1) && ISNUM(2) && ISNUM(3) && ISNUM(4) )
  33.    {
  34.        double  purchase = _parnd(1);
  35.        double  resale   = _parnd(2);
  36.        int     totper   = (int)_parnd(3);
  37.        int     periods  = (int)_parnd(4);
  38.  
  39.        _retnd((periods >= totper ? 0.0 :
  40.                          purchase - periods * ((purchase-resale) / totper)));
  41.    }
  42.    else
  43.       _retnd( (double)ERROR );
  44. }
  45.